package nccloud.sso.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import nc.bs.framework.adaptor.IHttpServletAdaptor;
import nccloud.sso.dto.SSOParamDTO;
import nccloud.sso.util.SSOUtils;

public class ApprPageServlet extends HttpServlet implements IHttpServletAdaptor {

	@Override
	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html; charset=UTF-8");
		String apprparam = req.getParameter("apprparam");
		SSOParamDTO param = SSOUtils.loadSysParam(new SSOParamDTO());
		resp.getWriter().write("<script>\r\n" + 
				"    window.open(\"http://"+param.getIp()+":"+param.getPort()+"/nccloud/sso/visit.action?apprparam="+apprparam+"\",\"_self\",\"\");\r\n" + 
				"</script>");
	}
	
	
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doAction(req, resp);	
	}
	
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doAction(req, resp);	
	}


	
}
